<style type="text/css">
    .layui-table-body{overflow-x:auto;}
    .layui-table-cell{font-size:12px;}
</style>
<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">开始时间</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="bg_time" type="text" placeholder="选择查询开始时间" name="bg_time">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">结束时间</label>
            <div class="layui-input-inline">
                <input class="layui-input" id="ed_time" type="text" placeholder="选择查询结束时间" name="ed_time">
            </div>
        </div>

        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">查询</button>
            </div>
        </div>
    </form>
</div>
<table id="dataTable"></table>
<script type="text/html" id="goodsTpl">
    <div style="line-height:18px;min-width: 200px;">
            <img src="{{ d.img ? d.img : '__ADMIN_IMG__/avatar.png' }}" width="60" height="60" style="display: block;">
    </div>
    <br/>
</script>

<script type="text/html" id="quanTpl">
    <div style="line-height:18px;min-width: 200px;">
            <p class="ml10 fl">{{ d.quan_name?d.quan_name:'否' }}</p><br>
            <p class="ml10 fl">优惠券抵扣价格:{{ d.quan_price>0?d.quan_price:0 }}</p>
    </div>
    <br/>
</script>

<script type="text/html" title="操作按钮模板" id="buttonTpl">
    {{#if (d.pay_status==1&&d.is_send==0&&d.refund_status==0){}}
    <a href="{:url('sendGoods')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe-pop"  hisi-data="{width: '1000px', height: '600px', title: '发货'}">发货</a>
    {{#}}}
    {{#if (d.is_refund==1){}}
    <a href="{:url('refund')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger">确认退款</a>
    {{#}}}
    <!-- <a href="{:url('del')}?type=goods&id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a> -->
</script>
{include file="system@block/layui" /}
<script id="toolbar" type="text/html">
    <!-- <a href="{:url('add')}?type=goods" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '1000px', height: '500px', title: '添加商品'}">&nbsp;添加</a> -->
    <a href="{:url('goods_export')}" class="layui-btn layui-btn-primary layui-icon layui-icon-play" width="460" height="270">&nbsp;导出</a>
    <!-- <button type="button" class="layui-btn" id="test1">
        <i class="layui-icon">&#xe67c;</i>导入excel
      </button> -->
</script>
<script type="text/javascript">
    layui.use(['table'], function() {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: false //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '暂无相关数据'
            }
            ,toolbar: true
            // ,title:'用户订单列表'
            ,totalrow:true
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {field: 'pai', title: '排名'}
                ,{title: '商品图', templet: '#goodsTpl'}
                ,{field: 'name', title: '商品名称'}
                // ,{title: '商品详情', templet: '#goodsTpl',width:350}
                ,{field: 'all_sell_num', title: '商品销量'}
                // ,{title: '是否使用优惠券',templet:'#quanTpl'}
                ,{field: 'all_sell_money', title: '销售额（元）'}
                // ,{field: 'refund_num', title: '退款订单/笔'}
                // ,{field: 'order_price', title: '订单金额'}
                // ,{field: 'ctime', title: '订单提交时间'}
                // ,{title: '订单状态',templet:'#orderStatus'}
                // ,{title: '操作', width: 180, templet: '#buttonTpl'}
            ]]
            ,done: function(){
                if (typeof(layui.global.addTableTool) !== 'undefined') {
                    layui.global.addTableTool();
                }
            }
        });
    });

    layui.use('upload', function(){
        var upload = layui.upload; //得到 upload 对象
        //创建一个上传组件
        upload.render({
        elem: '#test1'
        ,url: '{:url("goods_import")}'
        ,method:'post'
        ,done: function(res){ //上传后的回调
            // console.log(res);
            if(res.status=='success'){
                layer.msg('导入成功');
                window.location.reload();
            }
            else{
                layer.msg(res.msg);
            }
        } 
        ,accept: 'file' //允许上传的文件类型
        //,size: 50 //最大允许上传的文件大小
        //,……
        })
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#bg_time'
            ,type: 'datetime'
        });
    });

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#ed_time'
            ,type: 'datetime'
        });
    });
</script>